Il n’est pas possible d’introduire un rAmCharts dans un shiny. L’erreur suivante apparaît : impossible de trouver la fonction “controlShinyPlot”…
moy <- mean(grandile$AGE)
median <- median(grandile$AGE)
q1 <- quantile(grandile$AGE,0.25)
q3 <- quantile(grandile$AGE,0.75)
indic_centrale_age <- data.frame(moy,median,q1,q3)
indic_centrale_age %>% map_chr(format_box)
#> moy median q1 q3
#> "51,8" "50,0" "37,0" "66,0"
format_box(mean(grandile$PATRIMOINE))
#> [1] "383 070,1"
moy <- mean(grandile$AGE)
format_box(moy)
#> [1] "51,8"tab <- tab_moyenne(grandile,"PCS","AGE")
#Fonction pour calculer la variation inter-groupe sur la quanti
inter <- sum(tab$Contrib_inter)
format_box(inter)
#> [1] "211,6"
#Fonction pour calculer la variation intra-groupe sur la quanti
intra <- sum(tab$Contrib_intra)
format_box(intra)
#> [1] "139,7"
#Variance sur la quanti
var <- var(grandile[,"AGE"])
format_box(var)
#> [1] "351,0"
#Rapport de corrélation
eta2 <- (inter/var)*100
paste(format_box(eta2),"%")
#> [1] "60,3 %"
# #' simul_moyenne
# #'
# #' Fonction qui simule une série d'estimations d'indicateurs
# #' à l'aide de la moyenne empirique
# #'
# #' @param data un dataframe
# #' @param var une variable quantitative
# #' @param taille_echant taille de l'échantillon tiré
# #' @param nbr_simul nombre de tirage d'échantillons
# #'
# #' @return un vecteur numérique
# #' @export
# #'
# #' @examples simul_moyenne(grandile,"AGE",1000,1000)
# simul_moyenne <- function(data,var,taille_echant,nbr_simul){
# replicate(nbr_simul, {
# a <- data %>% sample_n(taille_echant)
# b <- mean(a[,var])
# b
# })
# }
#
# #' histoplotly_simul
# #'
# #' Histogramme de la simulation d'estimation avec la moyenne empirique
# #'
# #' @param serie un vecteur numérique
# #' @param var une variable quantitative
# #'
# #' @return un graphique GGPLOT2
# #' @export
# #'
# #' @examples
# #' a <- simul_moyenne(grandile,"AGE",1000,1000)
# #' histoplotly_simul(a,"AGE")
# histoplotly_simul <- function(serie,var){
# a <- serie %>% as.data.frame() %>% rename({{var}} := ".")
# ggplot(a) + aes(.data[[var]])+geom_histogram()
#
# }
dt <- grandile %>% mutate(PAUVRE = ifelse(PAUVRE == "1",TRUE,FALSE))
a <- simul_moyenne(dt,"PAUVRE",1000,1000)*100
histoplotly_simul(a,"PAUVRE")
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.b <- simul_moyenne(dt,"AGE",1000,1000)
histoplotly_simul(b,"AGE")
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.c <- simul_moyenne(dt,"REV_DISPONIBLE",1000,1000)
histoplotly_simul(c,"REV_DISPONIBLE")
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.d <- simul_moyenne(dt,"PATRIMOINE",1000,1000)
histoplotly_simul(d,"PATRIMOINE")
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.